package cn.kgc.vueprohou.service;

import cn.kgc.vueprohou.mapper.ProductMapper;
import cn.kgc.vueprohou.pojo.Product;
import cn.kgc.vueprohou.pojo.ProductExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class ProductServiceImpl implements ProductService {
    @Resource
    ProductMapper productMapper;
    @Override
    public List<Product> sele() {
        return productMapper.selectByExample(null);
    }

    @Override
    public Product seleById(Integer id) {
    if(id!=0){
        ProductExample example=new ProductExample();
        ProductExample.Criteria criteria = example.createCriteria();
        criteria.andIdEqualTo(id);
        List<Product> products = productMapper.selectByExample(example);
    return products.get(0);
    }else{
        return null;
    }
    }


    @Override
    public Integer up(Product product) {

        return productMapper.updateByPrimaryKeySelective(product);
    }
}
